package zhtt.eureka.server.controller;

import com.alibaba.fastjson.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author zhaott
 * @date: 2019/12/7 16:45
 **/
@RestController
public class EurekaAController {

    @Autowired
    private DiscoveryClient client;

    @RequestMapping(value="/serviceA", method= RequestMethod.GET)
    public String service() {
        System.out.println(JSONObject.toJSONString(client.getLocalServiceInstance()));
        System.out.println(" print info service A.");
        return "service A";
    }

    @RequestMapping(value="/print", method=RequestMethod.GET)
    public void print() {
        System.out.println(" print info.");
    }

    @RequestMapping(value="/beforeService", method=RequestMethod.GET)
    public String beforeService() {
        System.out.println(" print info service A beforeService.");
        return "Ready invoke service? ";
    }
}
